<!DOCTYPE html> 
<html>

<head>
  <title></title>
  
  
  
  <?php
      include_once('head.php'); 
   ?> 
  
  <script>  
  
  
  
 // $('#page-gift-budget').live('pageshow', function(event, ui) {
    //$('#page-gift-budget a.nextbutton').prepend('<div style="position: absolute; width: 16px; height: 17px; background: rgb(150, 174, 204); position: absolute; -webkit-transform: rotate(45deg); top: 3px; right: -8px; border: 1px solid rgba(0,0,0, 0.4); -webkit-box-shadow: 1px 0 0 rgba(255,255,255, 0.25), inset 1px 0 1px rgba(0,0,0, 0.2)"></div>');
    
    
		/*
		* OSS: in questo caso essendo le 2 pagine nello stesso file non è necessario
		* salvare le info nella sessione ma semplicemente basta recuperare i dati
		* dalle form. In questo caso è una prova.
		*/
	  
	  //alert('Parameter ID: ' + JSON.parse(sessionStorage.getItem('gift')).budget_min); 
    // alert('Parameter ID: ' + JSON.parse(sessionStorage.getItem('user')).name);
//  });
  
  
  $(document).ready(function(){
  
        
	/*
	
	// se radio = Group
	$('input#group_opt').live('change', function(){
      $('div#single_gift_option').hide();
      $('div#group_gift_option').show();
      $('a#fer').attr('href', '#page2');
      $('a#fer').attr('data-ajax', 'true');
  });
  
  
  // se radio = Single
  $('input#single_opt').live('change', function(){
      $('div#group_gift_option').hide();
      $('div#single_gift_option').show();
      $('a#fer').attr('href', 'page.gift_list.php');
      $('a#fer').attr('data-ajax', 'false');
  });
  
  */
  
  
	
	// $('div[data-role="fieldcontain"] fieldset div div:first-child label span span').html('<img src="/images/glyphish-icons-png/111-user.png" width="18px" height="16px"></img>');
	// $('div[data-role="fieldcontain"] fieldset div div:last-child label span span').html('<img src="/images/glyphish-icons-png/112-group.png" width="24px" height="16px"></img>');


	/*
	
  $('#group_gift_option input[name=budget]').click(function() {
    
    $("#group_gift_option input[type='radio']").attr("checked",false).checkboxradio("refresh");
        
    $(this).attr('checked', true).checkboxradio("refresh");
  
  });
  
 */
    
});



/* example:
  var name = new Person('Josh', 'Pepper', '25');

  sessionStorage.setItem('example', JSON.stringify(name));
  
  $('a#click').click(function(e){
      var temp = sessionStorage.getItem('example');
      var viewName = $.parseJSON(temp);
      var div = '<div>' + viewName.FirstName + ' ' + viewName.LastName + ' is ' + viewName.Age + ' years old.' + '</div>';
      $('div#show').html(div);
      e.preventDefault();
  });


  function Person(fName, lName, age){
      this.FirstName = fName;
      this.LastName = lName;
      this.Age = age;
      
  }
*/



  
  
</script>
  
</head>

  <body>
  
  
  
  <!-- PAGE 1: definizione budget e profilo destinatario -->
  
 <?php include('page.gift.budget.php');  ?>
 
 
 
 <!--  PAGE 2:  pagina di definizione del gruppo, inviando la mail agli amici -->
 
 <?php  include ('page.gift.group.amici.php'); ?>








  <script>



  // Jquery extension to get parameters from URL [GET] 
  $.extend({
	  getUrlVars: function(){
	    var vars = [], hash;
	    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	    for(var i = 0; i < hashes.length; i++)
	    {
	      hash = hashes[i].split('=');
	      vars.push(hash[0]);
	      vars[hash[0]] = hash[1];
	    }
	    return vars;
	  },
	  getUrlVar: function(name){
	    return $.getUrlVars()[name];
	  }
	});

  

  function Gift(giftname, giftdest, giftbudget, gifttype) {  
      this.name = giftname;
      this.dest = giftdest;      
      this.budget = giftbudget;   // budget can be for single or group
      this.type = gifttype;   
  }


	/*  Quando clicco su NEXT (se group vado sulla pagina delle 
	 *  mail altrimenti ai prodotti)
	 */ 
  
    $("#nextpage").click(function(e) {

			var giftname = 'prova'; //$('input[name=giftname]').val();
			var giftdest = 'p'; //$('input[name=giftdest]').val();
			var giftbudget = '';
			var gifttype = '';
			
			giftbudget = $('input[name=budget]:checked').val();
	
			// single or group 
			gifttype = $.getUrlVar('type');
			
			var gift = new Gift(giftname, giftdest, giftbudget, gifttype);
			
			// salvo l'oggetto gift in sessione 
			sessionStorage.setItem('gift', JSON.stringify(gift) );
		
  	});

    
  </script>
  

  </body>
</html>